﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CSharp.Libs.Koc;
using System.Collections;
using WPFColorPickerLib;

namespace CSharp.Libs.WPF.UserControls
{
    /// <summary>
    /// Interaktionslogik für AllianceCompareList.xaml
    /// </summary>
    public partial class AllianceCompareList : UserControl
    {
        #region declarations
        private AllianceMapViewViewModel _AMVVM = null;
        #endregion



        #region constructor destructor
        public AllianceCompareList()
        {
            InitializeComponent();
        }
        #endregion



        #region event handling
        private void mnuRemoveAllianceFromCompareList_Click(object sender, RoutedEventArgs e)
        {
            ArrayList aryItemsToRemove = new ArrayList();

            foreach (KocAllianceListItem KALI in lvAllianceCompareList.SelectedItems)
            {
                aryItemsToRemove.Add(KALI);
            }

            foreach (KocAllianceListItem KALI in aryItemsToRemove)
            {
                _AMVVM.AllianceCompareList.Remove(KALI);
            }
        }

        private void mnuEditAllianceColor_Click(object sender, RoutedEventArgs e)
        {
            if (lvAllianceCompareList.SelectedItems.Count == 1)
            {
                KocAllianceListItem KALI = (KocAllianceListItem)lvAllianceCompareList.SelectedItem;

                ColorDialog colorDialog = new ColorDialog();
                colorDialog.SelectedColor = KALI.Color.Color;
                if ((bool)colorDialog.ShowDialog())
                {
                    KALI.Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString(colorDialog.SelectedColor.ToString()));
                }
            }
        }
        #endregion



        #region private functions
        private void _Initialize(
            AllianceMapViewViewModel AMVVM)
        {
            _AMVVM = AMVVM;
            DataContext = _AMVVM;
        }
        #endregion



        #region interface
        #region methods
        public void Initialize(
            AllianceMapViewViewModel AMVVM)
        {
            _Initialize(AMVVM);
        }
        #endregion
        #endregion
    }
}
